package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import po.DyhBasedb;
import po.DyhReport;
import service.reportService;

import java.util.List;

/**
 * Created by napianlin on 2017/3/31.
 */
@Controller
@RequestMapping("/report")
public class reportController {

    @Autowired
    private reportService service;

    @RequestMapping("/gettopN")
    public String getTopN(@RequestParam Integer typeId) {
        List<DyhBasedb> list = service.getResportTopNByTypeId(typeId, 3);
        for (DyhBasedb m : list) {
            System.out.println(m.getObject() + ":次数为" + m.getsTimes());
        }
        return "index";
    }

    @RequestMapping("/detail")
    public String getDetail(@RequestParam(defaultValue = "0") Integer rid, Model model) {
        List<DyhReport> list= service.getReportsByRid(rid);
        model.addAttribute("list",list);
        return  "detail";
    }
}
